@echo off
set protectedApk=%1


@rem set variables.
set KEYSTORE_PATH=C:\Users\Lean\dev\android\Feifei\releaseKeystore.jks
set KEYSTORE_PASS=yiqikan123
set APP_NAME=yiqikan
set APP_VERSION=v1.7
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set CHANNEL=%DIRNAME%\channel.txt
set outDir=%APP_NAME%-%APP_VERSION%
set BASE_APK_PATH=%DIRNAME%\%APP_NAME%-release-%APP_VERSION%-base.apk

echo %DIRNAME%

@rem align apk
echo ===============start zipalign =====================
zipalign.exe -v -p 4 %protectedApk% jiagu-aligned.apk

@rem sign apk
echo ===============start sign =====================
start apksigner.bat sign --ks %KEYSTORE_PATH% --ks-pass pass:%KEYSTORE_PASS% --out %BASE_APK_PATH% jiagu-aligned.apk
TIMEOUT /t 3
echo =============== signed successful =====================


@rem vas dolly 
echo ===============VasDolly processing =====================
java.exe -jar %DIRNAME%\VasDolly.jar put -c %CHANNEL% %BASE_APK_PATH% %outDir%
echo ===============VasDolly successful =====================

@rem clear cache
echo ===============clear temp files ==================
DEL %BASE_APK_PATH%
DEL *.idsig
DEL jiagu-aligned.apk
echo ===============temp files cleared.==================
